<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:insert="~{include :: header('课程订单列表')}" />
    <th:block th:insert="~{include :: bootstrap-table-css}" />
</head>
<body class="hold-transition">
<div class="container-fluid mb-2">
    <div class="toolbar" id="toolbar" role="group">
        <form id="formId" class="form-inline">
            <input type="text" class="form-control mr-1" placeholder="订单id/订单编号" name="orderNo"/>
            <button type="button" class="btn btn-primary mr-1" onclick="$.table.search()">
                <i class="fa fa-search"></i> 搜索
            </button>
            <button type="button" class="btn btn-warning mr-1" onclick="$.form.reset()">
                <i class="fa fa-refresh"></i> 重置
            </button>
        </form>
    </div>
    <table id="bootstrap-table" class="table-striped"></table>
</div>
<th:block th:insert="~{include :: footer}" />
<th:block th:insert="~{include :: bootstrap-table-js}" />
<script th:inline="javascript">
    var orderTypeDatas = [[${@dict.getType('qdx_order_type')}]];
    var statusDatas = [[${@dict.getType('qdx_order_state')}]];
    $(function() {
        var options = {
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            url: "/my/order/list.json",
            modalName: "订单详情",
            columns: [
                {
                    field: 'orderId',
                    title: '订单id'
                },
                {
                    field: 'orderNo',
                    title: '订单号', formatter: function (value, row, index) {
                        return "<a href='javascript:void(0)' onclick=orderInfo('"+value+"')>"+value+"</a>";
                    }
                },
                {
                    field: 'userName',
                    title: '用户名'
                },
                {
                    field: 'payAmount',
                    title: '金额',
                    formatter: function(value, row, index) {
                        return row.payAmount / 100;
                    }
                },
                {
                    field: 'status',
                    title: '状态',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(statusDatas, value);
                    }
                },
                {
                    field: 'orderType',
                    title: '类型',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(orderTypeDatas, value);
                    }
                },
                {
                    field: 'createTime',
                    title: '下单时间'
                },
                {
                    title: '操作',
                    align: 'left',
                    width: '120px',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-info btn-xs " href="javascript:void(0)" onclick=orderInfo(\'' + row.orderNo + '\')><i class="fa fa-search"></i>详情</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    //订单详情页
    function orderInfo(orderNo) {
        layer.open({
            type: 2,
            area: ['90%', '95%'],
            fix: false,
            maxmin: true,
            shade: 0.3,
            title: "订单详情",
            content: "/my/order/view.html?orderNo="+orderNo
        });
    }
</script>
</body>
</html>